package OnJava8.functional;

/**
 * @Auther DRevelation
 * @Date 2020-05-20 下午 13:34
 * @Desc
 */
public class ResursiveFibonacci {
    IntCall fib;

    ResursiveFibonacci() {
        fib = n -> n == 0 ? 0
                : n == 1 ? 1
                : fib.call(n - 1) + fib.call(n - 2);
    }

    int fibonacci(int n) {
        return fib.call(n);
    }

    public static void main(String[] args) {
        ResursiveFibonacci rf = new ResursiveFibonacci();
        for (int i = 0; i < 10; i++) {
            System.out.println(rf.fibonacci(i));
        }
        System.out.println(rf.fibonacci(9));
    }
}
